package com.example.tool.module;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

@SuppressWarnings("SpellCheckingInspection")
public class ModuleInformation {
  public static final String MODULE_ID = "SeeyonTool";
  public static final String MODULE_NAME = "SeeyonTool";
  public static final String MODULE_DESCRIPTION = "基于致远OA项目快速创建Java模块";
  public static final int MODULE_WEIGHT = 20000;
  // 默认远程端口
  public static final String PORT = "5005";
  public static final String DEBUG_NAME = "RunDeBug";
  // 默认编译路径
  public static final String DIRECTORY = "seeyon";
  public static final String CONFIG_INFO = "配置信息";
  // 项目扩展到.idea文件名字
  public static final String MODULE_CONFIG = "seeyon.txt";
  public static final String MODULE_CONFIG_DB = "seeyonDB.txt";
  public static final String MODULE_SECRET_KEY = "SEEYON";
  // 错误提示
  public static final String All_INPUT = "请填写所有输入框！";
  public static final String PLUG_ID_MSG = "插件ID必须是英文字母或英文字母和数字组合（建议全部用小写字母）！";
  public static final String PLUG_CODE_MSG = "插件编码必须是数字类型！";
  public static final String DEBUG_PORT_MSG = "调试端口必须是数字类型！";
  // 菜单名称
  public static final String CONFIG_ACTION = "SeeyonTool配置";
  public static final String OPEN_FILE = "打开目录";
  public static final String BUILD_GROUP = "项目构建";
  public static final String BUILD_CONFIG = "扫描";
  public static final String UTIL_HTML = "HTML视图";
  public static final String BUILD_CONTROLLER = "控制层";
  public static final String BUILD_COLUMN = "自定义栏目";
  public static final String BUILD_MENU = "自定义菜单";
  public static final String BUILD_LISTENER = "监听事件";
  public static final String REST_GROUP = "构建Rest";
  public static final String REST_OUT = "外部访问资源";
  public static final String REST_UTIL = "Rest工具";
  public static final String REST_INTERFACE = "Rest接口";
  public static final String QUARTZ_GROUP = "定时任务";
  public static final String QUARTZ_QU = "Quartz定时任务";
  public static final String QUARTZ_TIMER = "Timer定时任务";
  public static final String FLOW_GROUP = "流程相关";
  public static final String FLOW_EVENT = "流程事件";
  public static final String FLOW_NODE = "超级节点";
  public static final String LOGIN_GROUP = "登录相关";
  public static final String LOGIN_SSO_IN = "单点登录";
  public static final String LOGIN_CUSTOM = "自定义登录";
  public static final String LOGIN_TRIPARTITE = "三方认证登录";
  public static final String TRIGGER_GROUP = "触发";
  public static final String TRIGGER_CAP3 = "CAP3触发";
  public static final String TRIGGER_CAP4 = "CAP4触发";
  public static final String CONTROLS_GROUP = "控件";
  public static final String CONTROLS_BTN = "自定义按钮";
  public static final String CONTROLS_CAP3 = "表单控件CAP3";
  public static final String CONTROLS_CAP4 = "表单控件CAP4";
  public static final String UTIL_GROUP = "工具集合";
  public static final String UTIL_MAP = "Map工具";
  public static final String UTIL_DATE = "日期工具";
  public static final String UTIL_MSG = "消息工具";
  public static final String UTIL_DENSE = "加解密工具";
  public static final String UTIL_ADDRESSBOOK = "组织自定义属性工具";
  public static final String UTIL_DAO_IN = "内部数据库查询工具";
  public static final String UTIL_DAO_OUT = "外部数据库查询工具";
  public static final String UTIL_OTHER = "其他工具";
  // 插件tip
  public static final String TIP = "说明";
  public static final String VIEW = "查看";
  public static final String CONFIG = "配置";
  public static final String CONFIG_DB = "配置数据库";
  public static final String REFRESH = "刷新";
  public static final String DEBUG_CONFIG_ERR = "远程代码同步配置异常";
  public static final String ILLUSTRATE = "组件元素个数为0，页面将不会出现可以与用户交互的元素组件！";
  public static final String DEBUG_CONFIG_ERR_MSG = "请安装：FTP/SFTP/WebDAV Connectivity插件！";
  public static final String DEBUG_CONFIG_TIP_MSG = "请设置自行设置同步！";
  public static final String IDEA_CONFIG_ERR_MSG = "请将隐藏目录.idea文件放出来";
  public static final String NO_CONFIG = "项目未配置SeeyonTool插件信息，请先配置插件信息后执行相关操作";
  public static final String NO_CONFIG_DB = "项目未配置SeeyonTool插件数据库信息，请先配置插件信息后执行相关操作";
  public static final String OPEN_ACTION_MSG = "打开菜单：{1} 出错！";
  public static final String TIP_FILE_IN = "<html><body>请输入对应的名称，所有文件均不需要输入后缀。{1}</body></html>";
  public static final String TIP_CREAT = "<html><body><span style='color: #F56C6C;'>根路径：</span>选择项目根目录即可(安装的项目路径 ApacheJetspeed 目录的<span style='color: #F56C6C;'>上级目录</span>)<br><span style='color: #F56C6C;'>插件ID：</span>必须为英文字符（建议全部用小写字母）<br><span style='color: #F56C6C;'>插件编码：</span>必须为数字</body></html>";
  public static final String TIP_CONFIG = "<html><body><span style='color: #F56C6C;'>根路径：</span>选择项目根目录即可(安装的项目路径 ApacheJetspeed 目录的<span style='color: #F56C6C;'>上级目录</span>)<br><span style='color: #F56C6C;'>源代码目录：</span>用于生成实体类时使用<br><span style='color: #F56C6C;'>插件ID：</span>必须为英文字符（建议全部用小写字母）<br>创建文件时生成的xml将在指定目录下，如下: <br><span style='color: #F56C6C;'>/编译目录/WEB-INF/cfgHome/plugin/插件ID/spring/</span></body></html>";
  public static final String TIP_SPRING_CONFIG = "<html><body>仅生成Spring配置XML文件，文件名称为<span style='color: #F56C6C;'>spring-{1}-config.xml</span><br>创建的xml文件将会保存在该路径中：<br><span style='color: #F56C6C;'>/{2}/WEB-INF/cfgHome/plugin/{1}/spring/</span></body></html>";
  public static final String TIP_CONTROLLER = "请求路径不以/开头和结尾";
  public static final String TIP_COLUMN = "<br>栏目的访问<span style='color: #F56C6C;'>请求类</span>为：类名+Controller<br>另外会生成两个前端文件：类名.html<span style='color: #F56C6C;'>（默认）</span>、类名+More.html<span style='color: #F56C6C;'>（更多）</span>";
  public static final String TIP_PACKAGE = "当前操作需要在 <span style='color: #F56C6C;'>{1}</span> 包下";
  public static final String TIP_TRIGGER = "<br>类名为声明触发的类名，<span style='color: #F56C6C;'>执行触发的类名</span>为：类名+Exe";
  public static final String TIP_CONTROLS = "<span style='color: #F56C6C;'>不同的版本可能会有偏差</span>";
  public static final String TIP_FORM = "<html><body><span style='color: #F56C6C;'>实体类字段：</span>只有单选表单才能选择<span style='color: #F56C6C;'>选定字段</span><br><span style='color: #F56C6C;'>字段转换类型：</span>数据库字段即数据库里面的列名<br>创建的<span style='color: #F56C6C;'>ENTITY</span>，保存在源码包为：<span style='color: #F56C6C;'>src_插件ID</span>中的<br> com/seeyon/apps/插件ID/<span style='color: #F56C6C;'>po</span><br><span style='color: #F56C6C;'>DAO</span>可以使用右键菜单中工具集合的数据库查询工具</body></html>";
  public static final String TIP_WINDOW_TABLE = "请至少选择一条数据";
  public static final String TIP_WINDOW_HAS = "多个表单生成，实体类字段不支持选定字段，请重新选择";

  /**
   * 字符串处理 将字符串中 {1} 替换为pares中第一个参数
   * @param subject 要处理的字符串
   * @param pares   处理字符串中替换的字符
   * @return 处理完的字符串
   */
  public static String textParse(String subject, String... pares) {
    if (pares != null) {
      for (int i = 0; i < pares.length; i++) {
        subject = subject.replaceAll("\\{" + (i + 1) + "\\}", pares[i]);
      }
    }
    String regex = "\\{\\d+\\}";
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(subject);
    return matcher.replaceAll("");
  }
}
